package com.robmayhew.jsc;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintWriter;
import java.io.FileWriter;

/**
 * Created by IntelliJ IDEA.
 * User: Rob
 * Date: 5-Apr-2005
 * Time: 9:08:11 PM
 * To change this template use File | Settings | File Templates.
 */
public class OutputFileAsWords
{
    public static void main(String[] args)
    {
        try
        {
            String fileIn = args[0];
            String fileOut = args[1];
            StringBuffer sb = new StringBuffer();
            BufferedReader in = new BufferedReader(new FileReader(fileIn));
            while (in.ready())
            {
                sb.append(in.readLine());
                sb.append("\n");
            }
            PrintWriter out = new PrintWriter(new FileWriter(fileOut));
            JavaSrcWordTokenizer jswt = new JavaSrcWordTokenizer(sb.toString());
            JavaSrcTokenList tokens = jswt.getTokens();
            for(int i = 0; i < tokens.size(); i++)
            {
                JavaSrcToken token = tokens.getToken(i);
                out.println(token.toString());
                out.flush();
            }
            out.close();
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}
